package org.jseries.network;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class WatchedDevice implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
	private String macAddress; //id
	private String ipAddress;
	@Temporal(TemporalType.TIMESTAMP)
	private Date inserted;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastReached;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastScanned;
	
	public WatchedDevice(String macAddress) {
		super();
		this.macAddress = macAddress;
	}
	
	public WatchedDevice(String macAddress, String ipAddress) {
		super();
		this.macAddress = macAddress;
		this.ipAddress = ipAddress;
	}
	
	public WatchedDevice() {
		super();
	}

	public String getMacAddress() {
		return macAddress;
	}

	public void setMacAddress(String macAddress) {
		this.macAddress = macAddress;
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	public Date getInserted() {
		return inserted;
	}

	public void setInserted(Date inserted) {
		this.inserted = inserted;
	}

	public Date getLastReached() {
		return lastReached;
	}

	public void setLastReached(Date lastReached) {
		this.lastReached = lastReached;
	}

	public Date getLastScanned() {
		return lastScanned;
	}

	public void setLastScanned(Date lastScanned) {
		this.lastScanned = lastScanned;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((macAddress == null) ? 0 : macAddress.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		WatchedDevice other = (WatchedDevice) obj;
		if (macAddress == null) {
			if (other.macAddress != null)
				return false;
		} else if (!macAddress.equals(other.macAddress))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "WatchedDevice [macAddress=" + macAddress + ", ipAddress="
				+ ipAddress + ", inserted=" + inserted + ", lastReached="
				+ lastReached + ", lastScanned=" + lastScanned + "]";
	}


}
